********************************************************************************
*
*	Date: May 23 2024 
*	This do-file replicates all tables and figures in: 
*	Karoline Larsen Kolstad. 2024. Overburdened Bureaucrats: Providing Equal Access to Public Services during Covid-19.
*	
*	by conducting all analysis based on data from Statistics Denmark reported in the online appendix. 
*
*	To produce all results three datasets are needed
*	1) aggregate_main
*	2) micro_main
*	3) micro_duration
*
********************************************************************************

cd "E:\workdata\708030\JOP_article"

log using "log_appendix.smcl", replace  

*******************************************************************************
*APPENDIX C: Parallel Trends Assumption 
*******************************************************************************

*Data 
use "data/micro_main.dta", clear 

*Figure C1
quietly: reg meeting year_week##industry_share_bi##ethnic if sample == 1 & year_week < 3133, cluster(municip_id) 

coefplot, vertical keep(*.year_week#*.industry_share_bi#*.ethnic) yline(0, lcolor(red)) xline(61, lcolor(blue)) xlabel(1 "2019w1" 20 "2019w20" 40 "2019w40" 63 "2020w13") ylabel(-0.07(0.03)0.07, nogrid) mcolor(black) ciopts(lcolor(black)) ytitle("Effects of Workload Exposure") graphregion(color(white)) 
qui graph export "output\fig_C1_trends.png", replace 

*******************************************************************************
*APPENDIX F: Descriptive Statistics  
*******************************************************************************

*Data
use "data/aggregate_main.dta", clear

*Figure F1 
histogram industry_share if island == 0 & clients >10, width(0.001) graphregion(color(white)) ytitle("Percent", size(medium)) title("") blcolor(gs10) bfcolor(gs10) percent xtitle("Share of jobs in lockdown affected industries", size(medium)) ylabel(0(5)15, labsize(small) nogrid) xlabel(0(0.01)0.05, nogrid labsize(small) nogrid)  
graph display, ysize(4) xsize(6) 
qui graph export "output\fig_F1_industry_share.png", replace

*Figure F2
histogram meetings if island == 0 & meetings < 0.4 & clients >10, width(0.005) graphregion(color(white)) ytitle("Percent", size(medium)) title("") blcolor(gs10) bfcolor(gs10) percent xtitle("Average number of caseworker meetings", size(medium)) ylabel(0(1)5, labsize(small) nogrid) xlabel(0(0.1)0.4, labsize(small) nogrid)  
graph display, ysize(4) xsize(6) 
qui graph export "output\fig_F2_meetings.png", replace

*Data 
use "data/micro_main.dta", clear 

*Table F1
estimates clear 
quietly: estpost sum  ethnic mena age_ gender education spell_seq sick_19 employ_19 meeting meeting_person meeting_digital activation if sample == 1 
esttab, replace cells("count mean(fmt(a2)) sd(fmt(a2)) min(fmt(a2)) max(fmt(a2))") nonumbers noobs label 

*******************************************************************************
*APPENDIX G: Meetings and Minimum Requirements   
*******************************************************************************

*Data 
use "data/aggregate_main.dta", clear

*Figure G1
tsline meetings_max meetings_min if year_week > 3120 & clients>10, ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0(0.05)0.15, labsize(small) nogrid) xlabel(3120 3130 3140 3155, nogrid labsize(small)) ///
title("") graphregion(color(white)) ytitle("Average meetings", size(medium)) ///
xtitle("Year, week", size(medium)) /// 
recast(line) lwidth(medium medium) lcolor(black black) lpattern(solid shortdash_dot) ///
legend(order(1 "> Min. requirements" 2 "<= Min. requirements") size(medium), ) ysc(titlegap(+3)) ///  
|| (pcarrowi 0.13 3128 0.13 3130 (9) "Lockdown" 0.14 3143 0.14 3141 (3) "Reopening", color(black) mlabcolor(black)) 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_G1_minimum_requirements.png", replace

*******************************************************************************
*APPENDIX H: Ethnic Minorities from MENA countries   
*******************************************************************************

*Data 
use "data/aggregate_main.dta", clear

*Figure H1 
twoway (scatter meetings_dk year_week if island == 0 & meetings_dk <0.4 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess meetings_dk year_week if island == 0 & treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5)) || ///
lowess meetings_dk year_week if island == 0 & treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5) || ///
lowess meetings_dk year_week if island == 0 & treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5) || ///
(scatter meetings_menap  year_week if island == 0 & island == 0 & meetings_menap <0.4 & clients_mena >10, msymbol(p) mcolor(gs10)) || ///
(lowess meetings_menap  year_week if island == 0 & treat_1 == 0 & island == 0 & clients_mena > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5)) || ///
lowess meetings_menap  year_week if island == 0 & treat_1 == 1 & island == 0 & clients_mena > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5) || ///
lowess meetings_menap  year_week if island == 0 & treat_2 == 1 & island == 0 & clients_mena > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(0.0(0.1)0.4, labsize(small) nogrid) xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("Average meetings", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.25 3125 0.25 3130 (9) "Lockdown" 0.3 3145 0.3 3141 (3) "Reopening", color(black) mlabcolor(black)) 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_H1_mena.png", replace

*Figure H2
twoway (scatter meetings_dk year_week if island == 0 & industry_share_bi ==0 & meetings_dk <0.25 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess meetings_dk year_week if island == 0 & treat_1 == 0 & industry_share_bi ==0, lcolor(black) lwidth(medthick)) ///
|| lowess meetings_dk year_week if island == 0 & treat_1 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| lowess meetings_dk year_week if island == 0 & treat_2 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| (scatter meetings_menap year_week if island == 0 & industry_share_bi ==0 & meetings_menap <0.25 & clients_mena >10, msymbol(p) mcolor(gs16)) ///
|| (lowess meetings_menap year_week if island == 0 & treat_1 == 0 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess meetings_menap year_week if island == 0 & treat_1 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess meetings_menap year_week if island == 0 & treat_2 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.05)0.25, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid)  ///
title("{bf:(a) Low Exposure}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("Average meetings", size(medium)) ///
xtitle("Year, week", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.2 3125 0.2 3130 (9) "Lockdown" 0.24 3145 0.24 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_low_menap.gph, replace)

twoway (scatter meetings_dk year_week if island == 0 & industry_share_bi ==1 & meetings_dk <0.25 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess meetings_dk year_week if island == 0 & treat_1 == 0 & industry_share_bi ==1, lcolor(black) lwidth(medthick)) ///
|| lowess meetings_dk year_week if island == 0 & treat_1 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| lowess meetings_dk year_week if island == 0 & treat_2 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| (scatter meetings_menap year_week if island == 0 & industry_share_bi ==1 & meetings_menap <0.25 & clients_mena >10, msymbol(p) mcolor(gs16)) ///
|| (lowess meetings_menap year_week if island == 0 & treat_1 == 0 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess meetings_menap year_week if island == 0 & treat_1 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess meetings_menap year_week if island == 0 & treat_2 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.05)0.25, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid)  ///
title("{bf:(b) High Exposure}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("", size(medium)) ///
xtitle("Year, week", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.2 3125 0.2 3130 (9) "Lockdown" 0.24 3145 0.24 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_high_menap.gph, replace)

grc1leg output\did_low_menap.gph output\did_high_menap.gph, graphregion(color(white)) ycommon 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_H2_mena.png", replace


*******************************************************************************
*APPENDIX I: Digital and In-Person Meetings    
*******************************************************************************

*Data 
use "data/aggregate_main.dta", clear

*Figure I1 

*In-Person 
twoway (scatter meetings_person_dk year_week if island == 0 & meetings_person_dk <0.4 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess meetings_person_dk year_week if treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5)) || ///
lowess meetings_person_dk year_week if treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5) || ///
lowess meetings_person_dk year_week if treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5) || ///
(scatter meetings_person_ethnic  year_week if island == 0 & meetings_ethnic <0.4 & clients_ethnic > 10, msymbol(p) mcolor(gs10)) || ///
(lowess meetings_person_ethnic  year_week if treat_1 == 0 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5)) || ///
lowess meetings_person_ethnic  year_week if treat_1 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5) || ///
lowess meetings_person_ethnic  year_week if treat_2 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(0.0(0.1)0.4, labsize(small) nogrid) xlabel(3068 3097 3126 3155, nogrid labsize(small)) ///
title("{bf:(a) In-Person}", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("Average meetings", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.25 3125 0.25 3130 (9) "Lockdown" 0.3 3145 0.3 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\scatter_in_person.gph, replace) 

*Digital 
twoway (scatter meetings_digital_dk year_week if island == 0 & meetings_person_dk <0.4 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess meetings_digital_dk year_week if treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5)) || ///
lowess meetings_digital_dk year_week if treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5) || ///
lowess meetings_digital_dk year_week if treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) bwidth(0.5) || ///
(scatter meetings_digital_ethnic  year_week if island == 0 & meetings_ethnic <0.4 & clients_ethnic > 10, msymbol(p) mcolor(gs10)) || ///
(lowess meetings_digital_ethnic  year_week if treat_1 == 0 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5)) || ///
lowess meetings_digital_ethnic  year_week if treat_1 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5) || ///
lowess meetings_digital_ethnic  year_week if treat_2 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) bwidth(0.5) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(0.0(0.1)0.4, labsize(small) nogrid) xlabel(3068 3097 3126 3155, nogrid labsize(small)) ///
title("{bf:(b) Digital}", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.25 3125 0.25 3130 (9) "Lockdown" 0.3 3145 0.3 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
 saving(output\scatter_digi.gph, replace) 

grc1leg output\scatter_in_person.gph output\scatter_digi.gph, graphregion(color(white)) 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_I1_digital.png", replace

*Figure I2
*In person-meetings, low exposure 
twoway (scatter meetings_person_dk year_week if island == 0 & industry_share_bi ==0 & meetings_dk <0.25 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess meetings_person_dk year_week if island == 0 & treat_1 == 0 & industry_share_bi ==0, lcolor(black) lwidth(medthick)) ///
|| lowess meetings_person_dk year_week if island == 0 & treat_1 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| lowess meetings_person_dk year_week if island == 0 & treat_2 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| (scatter meetings_person_ethnic year_week if island == 0 & industry_share_bi ==0 & meetings_ethnic <0.25 & clients_ethnic >10, msymbol(p) mcolor(gs16)) ///
|| (lowess meetings_person_ethnic year_week if island == 0 & treat_1 == 0 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess meetings_person_ethnic year_week if island == 0 & treat_1 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess meetings_person_ethnic year_week if island == 0 & treat_2 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.1)0.3, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("{bf:(a) Low, In-Person}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("Average meetings", size(medium)) ///
xtitle("", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.25 3125 0.25 3130 (9) "Lockdown" 0.3 3145 0.3 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_low_industri_bi_per.gph, replace)

*In person-meetings, high exposure
twoway (scatter meetings_person_dk year_week if island == 0 & industry_share_bi ==1 & meetings_dk <0.25 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess meetings_person_dk year_week if island == 0 & treat_1 == 0 & industry_share_bi ==1, lcolor(black) lwidth(medthick)) ///
|| lowess meetings_person_dk year_week if island == 0 & treat_1 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| lowess meetings_person_dk year_week if  island == 0 &treat_2 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| (scatter meetings_person_ethnic year_week if island == 0 & industry_share_bi ==1 & meetings_ethnic <0.25 & clients_ethnic >10, msymbol(p) mcolor(gs16)) ///
|| (lowess meetings_person_ethnic year_week if island == 0 & treat_1 == 0 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess meetings_person_ethnic year_week if island == 0 & treat_1 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess meetings_person_ethnic year_week if island == 0 & treat_2 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.1)0.3, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("{bf:(b) High, In-Person}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("", size(medium)) ///
xtitle("", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.25 3125 0.25 3130 (9) "Lockdown" 0.3 3145 0.3 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_high_industri_bi_per.gph, replace)

*Digital meeting, low exposure
twoway (scatter meetings_digital_dk year_week if island == 0 & industry_share_bi ==0 & meetings_dk <0.25 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess meetings_digital_dk year_week if island == 0 & treat_1 == 0 & industry_share_bi ==0, lcolor(black) lwidth(medthick)) ///
|| lowess meetings_digital_dk year_week if island == 0 & treat_1 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| lowess meetings_digital_dk year_week if island == 0 & treat_2 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| (scatter meetings_digital_ethnic year_week if island == 0 & industry_share_bi ==0 & meetings_ethnic <0.25 & clients_ethnic >10, msymbol(p) mcolor(gs16)) ///
|| (lowess meetings_digital_ethnic year_week if island == 0 & treat_1 == 0 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess meetings_digital_ethnic year_week if island == 0 & treat_1 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess meetings_digital_ethnic year_week if island == 0 & treat_2 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.1)0.3, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("{bf:(c) Low, Digital}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("Average meetings", size(medium)) ///
xtitle("Year, week", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.25 3125 0.25 3130 (9) "Lockdown" 0.3 3145 0.3 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_low_industri_bi_dig.gph, replace)

*Digital meeting, high exposure
twoway (scatter meetings_digital_dk year_week if industry_share_bi ==1 & meetings_dk <0.25 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess meetings_digital_dk year_week if island == 0 & treat_1 == 0 & industry_share_bi ==1, lcolor(black) lwidth(medthick)) ///
|| lowess meetings_digital_dk year_week if island == 0 & treat_1 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| lowess meetings_digital_dk year_week if island == 0 & treat_2 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| (scatter meetings_digital_ethnic year_week if island == 0 & industry_share_bi ==1 & meetings_ethnic <0.25 & clients_ethnic >10, msymbol(p) mcolor(gs16)) ///
|| (lowess meetings_digital_ethnic year_week if island == 0 & treat_1 == 0 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess meetings_digital_ethnic year_week if island == 0 & treat_1 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess meetings_digital_ethnic year_week if island == 0 & treat_2 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.1)0.3, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("{bf:(d) High, Digital}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("", size(medium)) ///
xtitle("Year, week", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.25 3125 0.25 3130 (9) "Lockdown" 0.3 3145 0.3 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_high_industri_bi_dig.gph, replace)

*Combine the four graphs into one 
grc1leg output\did_low_industri_bi_per.gph output\did_high_industri_bi_per.gph output\did_low_industri_bi_dig.gph output\did_high_industri_bi_dig.gph, graphregion(color(white)) ycommon 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_I2_digital.png", replace

*******************************************************************************
*APPENDIX J: Individuals with Similar Labor Market Characteristics    
*******************************************************************************

*Data 
use "data/micro_main.dta", clear 

*Table J1 
eststo z13: reg meeting treat_1##c.time_w11##ethnic if sample == 1 & industri_service == 1, cluster(municip_id) 
eststo z14: reg meeting treat_1##c.time_w11##ethnic if sample == 1 & education > 3 & education!=., cluster(municip_id) 
eststo z15: reg meeting treat_1##c.time_w11##ethnic if sample == 1 & employ_19 < 10, cluster(municip_id) 
eststo z16: reg meeting treat_1##c.time_w22##ethnic if sample == 1 & industri_service == 1, cluster(municip_id) 
eststo z17: reg meeting treat_1##c.time_w22##ethnic if sample == 1 & education > 3 & education!=., cluster(municip_id) 
eststo z18: reg meeting treat_1##c.time_w22##ethnic if sample == 1 & employ_19 < 10, cluster(municip_id) 

esttab z13 z14 z15 using output\tab_J1_w11_restrict.rtf, replace obslast se b(3) sfmt(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) noomitted nobaselevels nogaps title(Tabel J1) varwidth(40)
esttab z16 z17 z18 using output\tab_J1_w22_restrict.rtf, replace obslast se b(3) sfmt(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) noomitted nobaselevels nogaps title(Tabel J1) varwidth(40)

*Table J2
eststo z19: reg meeting treat_1##industry_share_bi##ethnic if sample == 1 & industri_service == 1, cluster(municip_id) 
eststo z20: reg meeting treat_1##industry_share_bi##ethnic if sample == 1 & education > 3 & education!=., cluster(municip_id) 
eststo z21: reg meeting treat_1##industry_share_bi##ethnic if sample == 1 & employ_19 < 10, cluster(municip_id) 
eststo z22: reg meeting treat_2##industry_share_bi##ethnic if sample == 1 & industri_service == 1, cluster(municip_id)
eststo z23: reg meeting treat_2##industry_share_bi##ethnic if sample == 1 & education > 3 & education!=., cluster(municip_id)
eststo z24: reg meeting treat_2##industry_share_bi##ethnic if sample == 1 & employ_19 < 10, cluster(municip_id) 

esttab z19 z20 z21 using output\tab_J2_w11_restrict.rtf, replace nobaselevels nogaps title(Tabel J2) se b(3) noomitted obslast varwidth(40) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
esttab z22 z23 z24 using output\tab_J2_w22_restrict.rtf, replace nobaselevels nogaps title(Tabel J2) se b(3) noomitted obslast varwidth(40) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


*******************************************************************************
*APPENDIX K: Activation Programs   
*******************************************************************************

*Data 
use "data/aggregate_main.dta", clear 

*Figure K1 
twoway (scatter activation_dk year_week if island == 0 & activation_dk <15 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_dk year_week if treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick)) || ///
lowess activation_dk year_week if treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick)  || ///
lowess activation_dk year_week if treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) || ///
(scatter activation_ethnic year_week if island == 0 & activation_ethnic <15 & clients_ethnic >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_ethnic  year_week if treat_1 == 0 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) ) || ///
lowess activation_ethnic  year_week if treat_1 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  || ///
lowess activation_ethnic  year_week if treat_2 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(, labsize(small) nogrid) xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("Average activation programs", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(cols(2) rows(1) position(6) order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.40 3125 0.40 3130 (9) "Lockdown" 0.50 3145 0.50 3141 (3) "Reopening", color(black) mlabcolor(black)) 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_K1_activation.png", replace

*Figure K2 
*Low exposure 
twoway (scatter activation_dk year_week if industry_share_bi ==0 & activation_dk <0.6 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess activation_dk year_week if treat_1 == 0 & industry_share_bi ==0, lcolor(black) lwidth(medthick)) ///
|| lowess activation_dk year_week if treat_1 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| lowess activation_dk year_week if treat_2 == 1 & industry_share_bi ==0, lcolor(black) lwidth(medthick) ///
|| (scatter activation_ethnic year_week if industry_share_bi ==0 & activation_ethnic <0.6 & clients_ethnic >10, msymbol(p) mcolor(gs16)) ///
|| (lowess activation_ethnic year_week if treat_1 == 0 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess activation_ethnic year_week if treat_1 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess activation_ethnic year_week if treat_2 == 1 & industry_share_bi ==0, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.2)0.6, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid)  ///
title("{bf:(a) Low exposure}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("Average activation programs", size(medium)) ///
xtitle("Year, week", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(cols(2) rows(1) position(6) order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.4 3125 0.4 3130 (9) "Lockdown" 0.50 3145 0.50 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_low_industri_bi.gph, replace)

*High exposure 
twoway (scatter activation_dk year_week if industry_share_bi ==1 & activation_dk <0.6 & clients_dk >10, msymbol(p) mcolor(gs10)) ///
|| (lowess activation_dk year_week if treat_1 == 0 & industry_share_bi ==1, lcolor(black) lwidth(medthick)) ///
|| lowess activation_dk year_week if treat_1 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| lowess activation_dk year_week if treat_2 == 1 & industry_share_bi ==1, lcolor(black) lwidth(medthick) ///
|| (scatter activation_ethnic year_week if industry_share_bi ==1 & activation_ethnic <0.6 & clients_ethnic >10, msymbol(p) mcolor(gs16)) ///
|| (lowess activation_ethnic year_week if treat_1 == 0 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick)) ///
|| lowess activation_ethnic year_week if treat_1 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
|| lowess activation_ethnic year_week if treat_2 == 1 & industry_share_bi ==1, lcolor(black) lpattern(shortdash) lwidth(medthick) ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ///
ylabel(0.0(0.2)0.6, labsize(small) nogrid) ///
xlabel(3068 3097 3126 3155, labsize(small) nogrid)  ///
title("{bf:(b) High exposure}", size(medium) color(black) margin(b=3)) ///
graphregion(color(white)) ytitle("", size(medium)) ///
xtitle("Year, week", size(medium)) ///
recast(line) ///
ysc(titlegap(+3)) ///
legend(cols(2) rows(1) position(6) order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ///
|| (pcarrowi 0.40 3125 0.40 3130 (9) "Lockdown" 0.50 3145 0.50 3141 (3) "Reopening", color(black) mlabcolor(black)), ///
saving(output\did_high_industri_bi.gph, replace)
 
grc1leg output\did_low_industri_bi.gph output\did_high_industri_bi.gph, graphregion(color(white)) ycommon 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_K2_activation.png", replace

*Figure K3 
*Internships
twoway (scatter activation_internship_dk year_week if island == 0 & activation_internship_dk <0.3 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_internship_dk year_week if treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick)) || ///
lowess activation_internship_dk year_week if treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick)  || ///
lowess activation_internship_dk year_week if treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) || ///
(scatter activation_internship_ethnic year_week if island == 0 & activation_internship_ethnic <0.3 & clients_ethnic >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_internship_ethnic year_week if treat_1 == 0 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) ) || ///
lowess activation_internship_ethnic year_week if treat_1 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  || ///
lowess activation_internship_ethnic year_week if treat_2 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(, labsize(small) nogrid) xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("Internships", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("Average activation programs", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(cols(2) rows(1) position(6) order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.20 3125 0.20 3130 (9) "Lockdown" 0.25 3145 0.25 3141 (3) "Reopening", color(black) mlabcolor(black)), saving(output\internship.gph, replace)
graph display, ysize(4) xsize(6)

*Skill devellopment
twoway (scatter activation_skills_dk year_week if island == 0 & activation_skills_dk <0.6 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_skills_dk year_week if treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick)) || ///
lowess activation_skills_dk year_week if treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick)  || ///
lowess activation_skills_dk year_week if treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) || ///
(scatter activation_skills_ethnic year_week if island == 0 & activation_skills_ethnic <0.6 & clients_ethnic >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_skills_ethnic year_week if treat_1 == 0 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) ) || ///
lowess activation_skills_ethnic year_week if treat_1 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  || ///
lowess activation_skills_ethnic year_week if treat_2 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(, labsize(small) nogrid) xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("Skill Devellopment", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(cols(2) rows(1) position(6) order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.40 3125 0.40 3130 (9) "Lockdown" 0.50 3145 0.50 3141 (3) "Reopening", color(black) mlabcolor(black)), saving(output\skills.gph, replace)
graph display, ysize(4) xsize(6)

*Education
twoway (scatter activation_education_dk year_week if island == 0 & activation_education_dk <0.3 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_education_dk year_week if treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick)) || ///
lowess activation_education_dk year_week if treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick)  || ///
lowess activation_education_dk year_week if treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) || ///
(scatter activation_education_ethnic year_week if island == 0 & activation_education_ethnic <0.3 & clients_ethnic >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_education_ethnic year_week if treat_1 == 0 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) ) || ///
lowess activation_education_ethnic year_week if treat_1 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  || ///
lowess activation_education_ethnic year_week if treat_2 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(, labsize(small) nogrid) xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("Ordinary Education", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("Average activation programs", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(cols(2) rows(1) position(6) order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.15 3125 0.15 3130 (9) "Lockdown" 0.20 3145 0.20 3141 (3) "Reopening", color(black) mlabcolor(black)), saving(output\education.gph, replace)
graph display, ysize(4) xsize(6)

*Wage subsidies
twoway (scatter activation_subsidy_dk year_week if island == 0 & activation_subsidy_dk <0.7 & clients_dk >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_subsidy_dk year_week if treat_1 == 0 & island == 0, lcolor(black) lwidth(medthick)) || ///
lowess activation_subsidy_dk year_week if treat_1 == 1 & island == 0, lcolor(black) lwidth(medthick)  || ///
lowess activation_subsidy_dk year_week if treat_2 == 1 & island == 0, lcolor(black) lwidth(medthick) || ///
(scatter activation_subsidy_ethnic year_week if island == 0 & activation_subsidy_ethnic <0.7 & clients_ethnic >10, msymbol(p) mcolor(gs10)) || ///
(lowess activation_subsidy_ethnic year_week if treat_1 == 0 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash) ) || ///
lowess activation_subsidy_ethnic year_week if treat_1 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  || ///
lowess activation_subsidy_ethnic year_week if treat_2 == 1 & island == 0 & clients_ethnic > 10, lcolor(black) lwidth(medthick) lpattern(shortdash)  ///
xline(3130 3141, lcolor(black*0.8) lp(dash) lwidth(vthin)) ylabel(, labsize(small) nogrid) xlabel(3068 3097 3126 3155, labsize(small) nogrid) ///
title("Wage Subsidies", size(medium) color(black) margin(b=3)) graphregion(color(white)) ytitle("", size(medium)) ///
xtitle("Year, week", size(medium)) recast(line) legend(cols(2) rows(1) position(6) order(2 "Danish majority" 6 "Non-western minority") size(small) symxsize(7)) ysc(titlegap(+3)) ///
|| (pcarrowi 0.10 3125 0.10 3130 (9) "Lockdown" 0.14 3145 0.14 3141 (3) "Reopening", color(black) mlabcolor(black)), saving(output\subsidy.gph, replace)
graph display, ysize(4) xsize(6)

grc1leg output\internship.gph output\skills.gph output\education.gph output\subsidy.gph, graphregion(color(white)) 
graph display, ysize(4) xsize(6)
qui graph export "output\fig_K3_activation.png", replace


*Data 
use "data/micro_main.dta", clear

*Table K1 
eststo a1: reg activation treat_1##c.time_w11##ethnic if sample == 1, cluster(municip_id) 
eststo a2: reg activation treat_1##c.time_w11##ethnic spell_seq c.education c.gender age sick_19 employ_19 if sample == 1, cluster(municip_id)
eststo a3: reg activation treat_2##c.time_w22##ethnic if sample == 1, cluster(municip_id) 
eststo a4: reg activation treat_2##c.time_w22##ethnic spell_seq c.education c.gender age sick_19 employ_19 if sample == 1, cluster(municip_id)
 
esttab a1 a2 using output\tab_K1_its_w11.rtf, replace obslast se b(3) sfmt(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) noomitted nobaselevels nogaps title() varwidth(40)
esttab a3 a4 using output\tab_K1_its_w22.rtf, replace obslast se b(3) sfmt(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) noomitted nobaselevels nogaps title() varwidth(40)

*Table K2
eststo b1: reg activation treat_1##industry_share_bi##ethnic if sample == 1, cluster(municip_id)
eststo b2: reg activation treat_1##industry_share_bi##ethnic spell_seq c.education c.gender age sick_19 employ_19 if sample == 1, cluster(municip_id)
eststo b3: reg activation treat_2##industry_share_bi##ethnic if sample == 1, cluster(municip_id)
eststo b4: reg activation treat_2##industry_share_bi##ethnic spell_seq c.education c.gender age sick_19 employ_19 if sample == 1, cluster(municip_id)

esttab b1 b2 using output\tab_K2_did_w11.rtf, replace nobaselevels nogaps title() se b(3) noomitted obslast varwidth(40) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
esttab b3 b4 using output\tab_K2_did_w22.rtf, replace nobaselevels nogaps title() se b(3) noomitted obslast varwidth(40) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


********************************************************************************
*APPENDIX L: Ethnicity and Unemployment Duration   
********************************************************************************

*Data 
use "data/micro_duration.dta", clear

*Figure L1: Ethnicity and Unemployment Duration 
stset spell, failure(failure==1) //Declare data to be survival data
sts test ethnicity, logrank //Conducts log-rank test
stcox i.ethnicity //Calculates the hazard ratios 

sts graph, by(ethnicity) graphregion(color(white)) plot1opts(color(gs15) lstyle(solid))  ///
ytitle("Propability of staying unemployed", size(medium)) xtitle("Weeks to event", size(medium)) ///
legend(order(1 "Danish majority" 2 "Non-western minority") ring(0) pos(2) col(1) region(lstyle(none)) symxsize(5)) ///
xlabel(1(4)30, labsize(small) nogrid) ylabel(0(0.2)1, labsize(small) nogrid) ///
title("", size(medium) color(black)) xsc(titlegap(+1)) ysc(titlegap(+3)) /// 
note("Hazard ratio, 0.70 (0.66-0.73)" "P=0.00 by log-rank test", ring(0) margin(medium))
qui graph export "output\fig_7_survival.png", replace

********************************************************************************

log close 
translate "log_appendix.smcl" "log_appendix.pdf" 

********************************************************************************





